{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a305ac81",
   "metadata": {},
   "source": [
    "* 本周主要内容：图像识别（人脸识别）\n",
    "* 23春_API_人工智能与机器学习_week04"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bd911e13",
   "metadata": {},
   "source": [
    "# 上周内容\n",
    ">1.API文档阅读（考试）  \n",
    ">2.request模块（考试）  \n",
    ">3.百度通用图像识别  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ffefcee1",
   "metadata": {},
   "source": [
    "# 本周内容"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6038f082",
   "metadata": {},
   "source": [
    "## 1.人脸识别概念和基础  \n",
    "## 2.人脸识别应用  \n",
    "## 3.人脸识别实践-face++  \n",
    ">1.人脸检测  \n",
    ">2.人脸比对+人脸搜索  \n",
    ">>1.人脸集合创建  \n",
    ">>2.人脸  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4dd27ea",
   "metadata": {},
   "source": [
    "# 人脸识别概念和基础\n",
    "https://zhuanlan.zhihu.com/p/36262110"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b3838137",
   "metadata": {},
   "outputs": [],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "Face++ 人脸检测\n",
    "'''\n",
    "\n",
    "request_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "# 二进制方式打开图片文件\n",
    "# 1.图片文件准备\n",
    "f = open('yyqx.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "# 2. 酬载准备\n",
    "payload = {\n",
    "    'api_key':'jRpCaZ34kqNYJ8Zppdc-yGGum_YkETov',\n",
    "    'api_secret':'Vr0PtRCw-ZFwYXTKVfi6aDNaSqlfunK3',\n",
    "    'image_base64':img,\n",
    "    'return_attributes':'gender,age,smiling,headpose,facequality,emotion,blur,beauty'\n",
    "}\n",
    "\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data = payload, headers=headers)\n",
    "if response:\n",
    "    print (response.json())\n",
    "else:\n",
    "    print(response.status_code)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
